﻿/*********************************************
FileName:ShowPopWnd.h
ProjectName:MobileManage
Created: mr.l
Time: 15/7/4.
*********************************************/
#pragma once
#ifndef __MobileManage__ShowPopWnd__
#define __MobileManage__ShowPopWnd__

#include "cocos2d.h"
#include "GNS_Common.h"
#include "GnsOften.h"
USING_NS_CC;

class GNS_PlayerMgr : public Layer
{
public:
    GNS_PlayerMgr();
    ~GNS_PlayerMgr();
    static GNS_PlayerMgr * GetInstance();
	long long FindListIndex(CMD_Mail *pMailInfo);
	CMD_Mail * FindMail(long long llRid);
	vector<CMD_Mail> * FindMail(long long ListIndex, short MailType);
	int GetMailCount(short MailType = MAIL_NULL);
	void DeleMailList(CMD_Mail* pMail);
	void AddMailList(CMD_Mail* pMail);
	void GetFriendListIndex(CMD_Mail *pMailInfo, long long &llListIndex, string &MailName);
	void GetMaxMailTypeCount(short &MailType, int &nCount);
	int GetMaxGiftMailCount();                     //获取所有礼品消息数目
	void SetSearchFriendData(CMD_FriendData *& pFriendData);	 //搜素好友的缓存

	void resetAll();    //重置所有
	int getAllMapListMailcount();	   //
	void clearSearchFriendData(){ m_mSearchFriend.clear(); }
	Vector<Node *>_NodeChildVec;
    Vector<Node *>_NodeHallVec;
    Vector<Layer *>_SecondNodeVec;
    int ChooseMonNum;
    int ChooseDayNum;
    int Test;
    Scene * pCurrScene;
private:
    static GNS_PlayerMgr * m_singleton;
	map<long long, CMD_FriendData> m_mSearchFriend;	   //缓存搜索好友的消息
public:
	map<long long, CMD_FriendData>* getSearFriendData()
	{
		return &m_mSearchFriend;
	}
    void setMyUseridx(long long idx){m_MyUserIdx = idx;}
    long long getMyUserIdx(){return m_MyUserIdx;}

	char *getMyPassMD5(){ return m_MyPassMD5; }
	char *getMyPassOgi(){ return m_MyPassOgi; }
	char *getMyNickName(){ return m_MyNickName; }

	void setMyUserInfo(char *name, char *passOgi, char *passMD5, char* editInviter)
	{
		memcpy(m_MyName, name, 32);
		m_MyName[strlen(name)] = 0;
		memcpy(m_MyPassOgi, passOgi, 32);
		m_MyPassOgi[strlen(passOgi)] = 0;
		memcpy(m_MyPassMD5, passMD5, 32);
		m_MyPassMD5[strlen(passMD5)] = 0;
		memcpy(m_MyPreferees, editInviter, 32);
		m_MyPreferees[strlen(editInviter)] = 0;
	}

	void setAgentID(int iAgentId){ m_iAgentId = iAgentId; }
	int getAgentID(){ return m_iAgentId; }

	char *getMyPreferees(){ return m_MyPreferees; }	    //获取推荐人ID
    
    void setMyNickName(char * name)
    {
		CCGnsOften::snprintf_safe(m_MyNickName, 33, name, strlen(name));
    }
    char * getMyName()
	{
		if (strlen(m_MyName) > 0)
		{
			return m_MyName;
		}	
		return nullptr;
	}

	void setMyLogoID(long long llLogoID){ m_MyLogoID = llLogoID; }
	long long getMyLogoID(){ return m_MyLogoID; }

    //存储获取当前版本
    void setCurrentVersionClient(int Version){m_VersionClient=Version;}
    int getCurrentVersionClient(){return m_VersionClient;}
    //存储获取更新地址
    std::string getUpdateURL(){return m_UpdateURL;}
    void setUpdateURL(std::string val){m_UpdateURL=val;}
    //存储获取服务器版本
    void setServerVersion(int version){m_VersionServer=version;}
    int getServerVersion(){return m_VersionServer;}
    //存储获取玩家级别
    void setUserLevel(int Level){nAgentLevent=Level;}
    int getUserLevel(){return nAgentLevent;}

	string getTwoCodeInfo(int n_index = 0);
	void SetTwoCodeInfo(string str, int index = 0);

	char* getMyNotice(){ return m_Notice; }
	void setMyNotice(char * notice)
	{
		memcpy(m_Notice, notice, sizeof(m_Notice));
		m_Notice[strlen(notice)] = 0;
	}

	char* getMyCellPhone(){ return m_CellPhone; }
	void setMyCellPhone(char * phone)
	{
		memcpy(m_CellPhone, phone, sizeof(m_CellPhone));
		m_CellPhone[strlen(phone)] = 0;
	}

	void setRecommendCode(int recommendCode)
	{
		m_Recommend = recommendCode;
	}
	int getRecommendCode(){ return m_Recommend; }

	//是否有未读邮件
	bool IsReadReceiptMail(long long  llListIndex, short MailType = MAIL_NULL);

	void UpdateMailToMapList(CMD_Mail* pMail);
	CMD_Mail * FindMailFromMapList(long long llRid);
	vector<CMD_Mail> *getSysMailList();// { return &m_SysMailList; }
	vector<CMD_Mail> *getFriendMailList();// { return &m_FriendMailList; }
	vector<CMD_Mail> *getReChargeMailList();// { return &m_ReChargeMailList; }
	vector<CMD_Mail> *getShareGoldMailList();// { return &m_ShareGoldMailList; }
	vector<CMD_Mail> *getReturnExchangeGoldMailList();
	vector<CMD_Mail> *getDeductionMailList();
	vector<CMD_Mail> *getDivideResult();


	map<long long, pair<string, vector<CMD_Mail> > > *getMapSysLietMail();//{ return &m_MapSysLietMail; };//保存 系统邮件列表 中每列对应的邮件
	map<long long, pair<string, vector<CMD_Mail> > > *getMapFriendLietMail();//{ return &m_MapFriendLietMail; };//保存 个人信息列表 中每列对应的邮件
	map<long long, pair<string, vector<CMD_Mail> > > *getMapReChargeMailList();//{ return &m_MapReChargeMailList; };//保存 点卡充值邮件列表 中每列对应的邮件
	map<long long, pair<string, vector<CMD_Mail> > > *getMapShareGoldMailList();//{ return &m_MapShareGoldMailList; };//保存 分享金币邮件列表 中每列对应的邮件
	map<long long, pair<string, vector<CMD_Mail> > > *getMapReturnExchangeGoldMailList();//保存 返还兑换金币邮件列表 中每列对应的邮件
	map<long long, pair<string, vector<CMD_Mail> > > *getMapDeductionMailList();//保存 扣除金币邮件列表 中每列对应的邮件
	map<long long, pair<string, vector<CMD_Mail> > > *getMapDivideResultMailList();//保存 扣除金币邮件列表 中每列对应的邮件

	// 与官方的联系方式
	CMD_ContactInformation* GetContactInfo()   { return &m_ContactInfo; }
	void SetContactInfo(CMD_ContactInformation val) { m_ContactInfo = val; }
	// key -- rankno(排行名次) value -- CMD_SC_GetRanking 结构
	map<int, CMD_SC_GetRanking> *getRankList(){ return &m_mRankList; }
	// 系统邮件列表
	//vector<CMD_Mail>	m_SysMailList;
	// 个人邮件列表
	//vector<CMD_Mail> m_FriendMailList;
	// 点卡充值邮件列表
	//vector<CMD_Mail> m_ReChargeMailList;
	// 分享金币邮件列表
	//vector<CMD_Mail> m_ShareGoldMailList;
	// 返还兑换金币邮件列表
	//vector<CMD_Mail> m_ReturnExchangeGoldMailList;
	//扣除金币邮件列表
	//vector<CMD_Mail> m_DeductionMailList;
	//下线贡献金币邮件
	//vector<CMD_Mail> m_DivideResultMailList;

	//所有邮件列表
	map<int, vector<CMD_Mail> > m_allVectorMailList;


	// 排行版列表
	map<int, CMD_SC_GetRanking> m_mRankList;

	//map<列表索引,pair<行文字，vector<CMD_Mail*> > >
	//map<long long, pair<string, vector<CMD_Mail> > > m_MapSysLietMail;//保存 系统邮件列表 中每列对应的邮件
	//map<long long, pair<string, vector<CMD_Mail> > > m_MapFriendLietMail;//保存 个人信息列表 中每列对应的邮件
	//map<long long, pair<string, vector<CMD_Mail> > > m_MapReChargeMailList;//保存 点卡充值邮件列表 中每列对应的邮件
	//map<long long, pair<string, vector<CMD_Mail> > > m_MapShareGoldMailList;//保存 分享金币邮件列表 中每列对应的邮件
	//map<long long, pair<string, vector<CMD_Mail> > > m_MapReturnExchangeGoldMailList;//保存 返还兑换金币邮件列表 中每列对应的邮件
	//map<long long, pair<string, vector<CMD_Mail> > > m_MapDeductionMailList;//保存 扣除金币邮件列表 中每列对应的邮件
	//map<long long, pair<string, vector<CMD_Mail> > > m_MapDivideResultMailList;//保存 下线贡献金币邮件

	//所有邮件map列表
	map<int, map<long long, pair<string, vector<CMD_Mail> > > > m_MapAllList;

	map<long long, CMD_FriendInfo> *getFriendList(){ return &m_mFriendList; }	  //获取牌友列表
	map<long long, CMD_InviteFriendInfo> *getInviteFriend(){ return &m_mInviteFriend; }	   //获取好友邀请列表

	// 牌友请求消息
	map<long long, CMD_InviteFriendInfo>  m_mInviteFriend;
	// 牌友列表
	map<long long, CMD_FriendInfo>			m_mFriendList;

	map<int, CMD_SC_HALLGAME_LIST>		m_GameInfoStruct;   //游戏列表的详细信息

	void setMyExperienceGold(LONGLONG Chip){ m_ExperienceGold = Chip; }
	LONGLONG getMyExperienceGold(){ return m_ExperienceGold; }

	void setMyGameGold(long long gameGold){ m_MyGameGold = gameGold; }
	long long getMyGameGold(){ return m_MyGameGold; }

	//设置游戏列表
	void SetGameInfoStruct(CMD_SC_HALLGAME_LIST * pHALLGAME_LIST)
	{
		CMD_SC_HALLGAME_LIST gameStruct = *pHALLGAME_LIST;
		//if (m_GameInfoStruct.find(pHALLGAME_LIST->nGameId) != m_GameInfoStruct.end())
			//return;
		m_GameInfoStruct[gameStruct.nGameId] = gameStruct;
	}

	static int GameInfoStruct_sort(pair<CMD_SC_HALLGAME_LIST, int> p1, pair<CMD_SC_HALLGAME_LIST, int> p2)
	{
		return p1.second < p2.second;
	}

	void SetGameInfoStruct()
	{
		m_GameInfoStruct.clear();
	}

	//vector<pair<GameInfoStruct, int> > getGameInfoStruct(){return m_GameInfoStruct;}
	map<int, CMD_SC_HALLGAME_LIST>* getGameInfoStruct(){ return &m_GameInfoStruct; }

	bool m_isKickout = false;   //帐号是否从其他地方登陆   
	bool m_isBaoji = false;		//是否爆机

	bool m_isGetAllGame = false;			//是否接收所有游戏
	void setGetAllGame(bool isFinish) { m_isGetAllGame = isFinish; }
	bool getGetAllGame() { return m_isGetAllGame; }

private:
    //玩家自己的数据
    long long m_MyUserIdx;
    long long m_MyLogID;
	long long m_MyLogoID;
	long long m_MyGameGold = 0;   //游戏币
	long long m_ExperienceGold = 0;       //体验币 
    char m_MyName[33];		  //帐号
	
	int m_iAgentId;
    char m_MyNickName[33];
	char m_MyPassOgi[33];
	char m_MyPassMD5[33];
	char m_MyPreferees[33];	  //推荐人id
	char m_CellPhone[33];     //手机号码
	//客户端版本
    int m_VersionClient;
	// 服务器版本
    int m_VersionServer;
    std::string m_UpdateURL;
    int nAgentLevent;
    std::map<int ,string> m_RemarkName; 
private:
	string m_szTwoCodeInfo;	//二維碼信息
	string m_szTwoCodeInfoIos;	//二維碼信息
	char m_Notice[512];		 //公告
	
	// 与官方的联系方式
	CMD_ContactInformation m_ContactInfo;

	int m_Recommend;
};

#endif /* defined(__MobileManage__ShowPopWnd__) */